home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBSETRCU.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  92 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbsetrcu.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <blkio.h>
  13. #include <lseq.h>
  14.  
  15. /* local headers */
  16. #include "cbase_.h"
  17.  
  18. /*man---------------------------------------------------------------------------
  19. NAME
  20.      cbsetrcur - set cbase record cursor
  21.  
  22. SYNOPSIS
  23.      #include <cbase.h>
  24.  
  25.      int cbsetrcur(cbp, cbrposp)
  26.      cbase_t *cbp;
  27.      const cbrpos_t *cbrposp;
  28.  
  29. DESCRIPTION
  30.      The cbsetrcur function sets the position of the record cursor of
  31.      cbase cbp to the value pointed to by cbposp.  If cbrposp is the
  32.      NULL pointer, the record cursor is set to null.
  33.  
  34.      cbsetrcur will fail if one or more of the following is true:
  35.  
  36.      [EINVAL]       cbp is not a valid cbase pointer.
  37.      [CBELOCK]      cbp is not locked.
  38.      [CBENOPEN]     cbp is not open.
  39.  
  40. SEE ALSO
  41.      cbgetrcur, cbrcursor, cbsetkcur.
  42.  
  43. DIAGNOSTICS
  44.      Upon successful completion, a value of 0 is returned.  Otherwise,
  45.      a value of -1 is returned, and errno set to indicate the error.
  46.  
  47. ------------------------------------------------------------------------------*/
  48. #ifdef AC_PROTO
  49. int cbsetrcur(cbase_t *cbp, const cbrpos_t *cbrposp)
  50. #else
  51. int cbsetrcur(cbp, cbrposp)
  52. cbase_t *cbp;
  53. const cbrpos_t *cbrposp;
  54. #endif
  55. {
  56.     lspos_t    lspos    = NIL;
  57.  
  58.     /* validate arguments */
  59.     if (!cb_valid(cbp)) {
  60.         errno = EINVAL;
  61.         return -1;
  62.     }
  63.  
  64.     /* check if not open */
  65.     if (!(cbp->flags & CBOPEN)) {
  66.         errno = CBENOPEN;
  67.         return -1;
  68.     }
  69.  
  70.     /* check if not locked */
  71.     if (!(cbp->flags & CBLOCKS)) {
  72.         errno = CBELOCK;
  73.         return -1;
  74.     }
  75.  
  76.     /* set record cursor position */
  77.     if (cbrposp == NULL) {
  78.         if (lssetcur(cbp->lsp, NULL) == -1) {
  79.             CBEPRINT;
  80.             return -1;
  81.         }
  82.     } else {
  83.         lspos = *cbrposp;
  84.         if (lssetcur(cbp->lsp, &lspos) == -1) {
  85.             CBEPRINT;
  86.             return -1;
  87.         }
  88.     }
  89.  
  90.     return 0;
  91. }
  92.